home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 2 / MacMania 2.toast / Demo's / Tools&Utilities / Programming / ViewIt 2.24 / FORTRAN Demo Projects / Absoft MacFortran II 3.2 Demos / Old MF 020 Stuff / vDemoMF.for < prev   
Encoding:
Text File  |  1994-03-12  |  4.6 KB  |  147 lines  |  [TEXT/EDIT]

  1. C ViewIt 2.2 Demonstration Program
  2. C ©FaceWare 1991-94.  All Rights Reserved.
  3.  
  4.       PROGRAM vDemoMF
  5.     implicit none
  6.     INTEGER*4 PTR
  7.     PARAMETER (PTR = Z'C0000000')
  8.     INTEGER DELAY
  9.     PARAMETER (DELAY=Z'03B80020')
  10.     INTEGER TICKCOUNT
  11.     PARAMETER (TICKCOUNT=Z'97580000')
  12.     INTEGER SETCTLVALUE
  13.     PARAMETER (SETCTLVALUE=Z'96311000')
  14.  
  15.     logical*4 helpShown
  16.     integer*2 myInteger,myList
  17.     integer*4 myFlags,myPtr,toolbx,oldTicks,newTicks
  18.     real*4 myReal,theReal,delta
  19.     character*100 myString
  20.     integer*1 myRec(110)
  21.     equivalence (myRec(1),myInteger)
  22.     equivalence (myRec(3),myReal)
  23.     equivalence (myRec(7),myString)
  24.     equivalence (myRec(107),myFlags)
  25.  
  26.       include FaceStorMF.inc
  27.  
  28. C For MF, "ctlprc" is necessary to support the "override" example.
  29. C ctlprc returns an address that can be passed to the OvrCtl command.
  30. C ctlprc is passed the name of the override routine and the number
  31. C of bytes (4) that will be passed by ViewIt when calling the routine.
  32.     integer*4 OverPtr,OverProc,ctlprc
  33.     external OverProc
  34.     OverPtr = ctlprc(OverProc,4)  !ctlprc locks itself into memory
  35.  
  36.     load JumpIt     !!!REMOVE this line if JumpIt is linked to program!!!
  37.     load toolbx  !!!REMOVE this line if toolbx is linked to program!!!
  38.  
  39.     myInteger = 0
  40.     myReal = 6.2
  41.     myString = 'Hello'
  42.     myFlags = 10
  43.     myList = 2
  44.     oldTicks = 0
  45.     theReal = 6.0
  46.  
  47. C Initialize FaceIt
  48.       uName = 'vDemo.Rsrc'
  49.       call FaceIt(0,DoInit,0,0,0,0)
  50.  
  51. C Open Modeless Window using FWND 1000
  52.     call FaceIt(0,NewWnd,1000,1,0,0)
  53.  
  54.       do
  55.         call FaceIt(0,DoLoop,0,0,0,0)
  56. C Standard "About" Menu Item Selection
  57.       if ((uMenuID = 101).and.(uMenuItem = 1)) then
  58.         uString = 'Demonstration of the use of ViewIt'
  59.      +//char(13)//'windows in a FaceIt-based program.'
  60.         call FaceIt(0,ShoStr,3,12,(1 + (409*65536)),0)
  61. C Hit in Modeless Window's "Open Modal" Button
  62.       else if ((uMenuID = 1000).and.(wcHit = 2)) then
  63.         call FaceIt(0,NewWnd,1001,0,0,0)  !Open Modal Window
  64.         do
  65.           call FaceIt(0,MdlWnd,1001,0,0,0)  !Process Modal Events
  66.         if (wcHit = -1) then            !Hit in Close Box
  67.           exit
  68.         else if (wcHit = 1) then        !Hit in "Open Nested"
  69.           myPtr = toolbx(PTR,myRec)
  70.           call FaceIt(0,NewWnd,1002,0,110,myPtr)!Open Nested Modal
  71.           call FaceIt(0,GetCtl,1002,0,3,3)      !Link Scrollable List
  72.           myPtr = toolbx(PTR,myList)
  73.           call FaceIt(0,LnkCtl,cControl,myPtr,2,0)
  74.           call FaceIt(0,GetCtl,1002,0,2,3)      !Set Override Proc
  75.           call FaceIt(0,OvrCtl,cControl,OverPtr,0,0)
  76.           call FaceIt(0,SetVal,1002,0,0,0)      !Set Linked Values
  77.           helpShown = .false.
  78.           do
  79.             call FaceIt(0,MdlWnd,1002,-2,0,0) !Process Modal Events
  80.             if (uMenuID = 0) then          !No Message
  81.               newTicks = toolbx(TICKCOUNT)
  82.             if (newTicks > oldTicks + 60) then
  83.               oldTicks = newTicks
  84.               call FaceIt(0,GetCtl,1002,0,2,8)
  85.               call toolbx(SETCTLVALUE,cControl,
  86.      +            mod(int(cValue),4) + 1)
  87.             end if
  88.             else if (wvHit = 1) then          !Hit in View #1
  89.               if (wcHit = 1) then          !Hit in "OK" Button
  90.               exit
  91.             else if (wcHit = 2) then      !Hit in "Show/Hide"
  92.               if (helpShown) then
  93.                 call FaceIt(0,ShoCtl,0,0,-3,2)    !Hide v3, Show v2
  94.                 helpShown = .false.
  95.               else
  96.                 call FaceIt(0,ShoCtl,0,0,-2,3)    !Hide v2, Show v3
  97.                 helpShown = .true.
  98.               end if
  99.             end if
  100.             else if (wvHit = 2) then          !Hit in View #2
  101.               if ((wcHit = 6).or.(wcHit = 7)) then
  102.               call FaceIt(0,GetCtl,1002,0,2,int(wcHit))
  103.               delta = 0.001 * (cMin - 2)
  104.               myReal = myReal + delta
  105.               call FaceIt(0,SetVal,1002,0,2,2)
  106.               call toolbx(DELAY,5,uI4)
  107.             end if
  108.             end if
  109.           repeat
  110.           call FaceIt(0,GetVal,1002,0,0,0)      !Get Linked Values
  111.           call FaceIt(0,EndWnd,1002,0,0,0)      !Close Nested Modal
  112.         end if
  113.         repeat
  114.         call FaceIt(0,EndWnd,1001,0,0,0)  !Close Modal Window
  115. C Hit in Modeless Window's "Why ViewIt?" Button
  116.       else if ((uMenuID = 1000).and.(wcHit = 3)) then
  117.         myPtr = toolbx(PTR,theReal)
  118.         call FaceIt(0,NewWnd,1003,0,0,myPtr)
  119.         call FaceIt(0,SetVal,1003,0,0,0)
  120.         do
  121.           call FaceIt(0,MdlWnd,1003,0,0,0)
  122.         if (wcHit = 1) exit
  123.         repeat
  124.         call FaceIt(0,GetVal,1003,0,0,0)
  125.         call FaceIt(0,EndWnd,1003,0,0,0)
  126.       end if
  127.     repeat
  128.       end
  129.  
  130. C The "OverPtr" passed to OvrCtl results in this routine being called
  131. C with a single 4-byte parameter that contains the address of the value
  132. C passed by ViewIt. The "long" function is then used to get "thePtr".
  133.     SUBROUTINE OverProc(argptr)
  134.     implicit none
  135.     integer*4 argptr,thePtr
  136.       include FaceStorMF.inc
  137.     thePtr = long(argptr)
  138.     if (uCommand = 264) then    !a key down message?
  139.       if (uParam(1) = 32) then    !SPACE key pressed?
  140.         uParam(1) = 95        !convert to UNDERLINE
  141.       end if
  142.     end if
  143.     call JumpIt(thePtr)        !pass message to driver
  144.     end
  145.  
  146.       include FaceProcMF.inc
  147.